package com.jzhao.gper.spring.v3.aop;

import com.jzhao.gper.spring.v3.aop.support.JZAdvisedSupport;

import java.lang.reflect.Proxy;

/**
 * @author jzhao
 * @date 2020/4/21 14:41
 */
public class JZDefaultAopProxyFactory {
    public JZAopProxy createAopProxy(JZAdvisedSupport config) {
        Class<?> targetClass = config.getTargetClass();
        if (targetClass.isInterface() || Proxy.isProxyClass(targetClass)) {
            return new JZJdkDynamicAopProxy(config);
        }
        return new JZObjenesisCglibAopProxy(config);
    }
}
